fix(seo): cache sitemap so Google can fetch it#34
Merged
Conversation
The sitemap was force-dynamic: with ~6.8k URLs × 15-locale hreflang it
regenerates in ~13s and serializes to ~12MB on every request, so Google
Search Console's fetcher times out ("Couldn't fetch", 0 URLs discovered).
Switch to ISR (revalidate = 3600): serve a cached copy and regenerate at
most hourly in the background, so crawlers always get a fast response. The
existing try/catch already tolerates the DB-less Docker build, which now
renders the static-routes fallback at build time; the first request after
deploy fills in agents/skills and caches the full sitemap.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
GSC reports "Couldn't fetch" (无法抓取) with 0 URLs discovered for
https://takoapi.com/sitemap.xml.Root cause:
sitemap.tsisforce-dynamic. With ~6,777 URLs each carrying 15-localehreflangalternates, it regenerates against the DB on every request — measured at ~13s and ~12MB. Google's sitemap fetcher times out on that. (Size is within Google's 50MB/50k-URL limits; generation time is the killer.)Fix
Switch from
force-dynamicto ISR (export const revalidate = 3600): serve a cached copy and regenerate at most hourly in the background (stale-while-revalidate), so crawlers always get a fast response.The existing
try/catchalready tolerates the DB-less Docker build, so the build-time render falls back to the static routes; the first request after deploy fills in agents/skills and caches the full sitemap. Catalog changes propagate within the hour — fine, since crawlers hit this infrequently.After deploy
Re-submit / let GSC re-fetch
sitemap.xml; the response is now fast and cacheable.🤖 Generated with Claude Code